package com.quanyan.stadium.service.gameEvent.impl;

import com.alibaba.dubbo.common.utils.CollectionUtils;
import com.google.gson.Gson;
import com.quanyan.api.APIResponse;
import com.quanyan.common.exception.BizException;
import com.quanyan.common.vo.Image;
import com.quanyan.place.entity.apiresp.RespDistrict;
import com.quanyan.stadium.api.req.gameEventConfig.ReqPersonCreateGameEvent;
import com.quanyan.stadium.api.resp.RespGameSystemAndGameCategory;
import com.quanyan.stadium.biz.BizGameSystemDao;
import com.quanyan.stadium.component.pushMsg.MsgPush;
import com.quanyan.stadium.constants.GameConstants;
import com.quanyan.stadium.entity.*;
import com.quanyan.stadium.entity.vo.GameEvent;
import com.quanyan.stadium.entity.vo.MultiMedia;
import com.quanyan.stadium.enums.*;
import com.quanyan.stadium.service.GameEventService;
import com.quanyan.stadium.service.commonComponent.BaseService;
import com.quanyan.stadium.service.commonComponent.GameMsgPush;
import com.quanyan.stadium.service.gameEvent.PersonGameEventConfigService;
import com.quanyan.stadium.service.gameRules.entity.GameRuleGenerate;
import com.quanyan.stadium.service.gameRules.impl.GameRulePkServiceImpl;
import com.quanyan.stadium.service.gameSign.GameSignUpService;
import com.quanyan.stadium.transfer.GameConfigTransfer;
import com.quanyan.stadium.utils.GameUtils;
import com.quanyan.statium.api.req.GameCategory;
import com.quanyan.user.response.RespUserInfoDetail;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

import java.util.*;

/**
 * Created by xiaoxiao on 16/10/9.
 *
 * 个人赛事的创建
 */
@Service
public class PersonGameEventConfigServiceImpl implements PersonGameEventConfigService {

    private static final Logger logger = LoggerFactory.getLogger(PersonGameEventConfigServiceImpl.class);

    @Autowired
    private BaseService baseService;

    @Autowired
    private BizGameSystemDao bizGameSystemDao;

    @Autowired
    private GameSignUpService gameSignUpService;

    @Autowired
    private GameRulePkServiceImpl gameRulePkServiceImpl;

    @Autowired
    private GameEventService gameEventService;

    @Value("${share.server.name}")
    private String shareServerName;

    @Autowired
    private GameMsgPush gameMsgPush;
    @Autowired
    private GameConfigTransfer gameEventTransfer;


    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public GameEvent createGameEvent(ReqPersonCreateGameEvent reqPersonCreateGameEvent, int uid) throws Exception {
        validateCondition(reqPersonCreateGameEvent);
        TbGameEvent tbGameEvent = transferTbGameEvent(reqPersonCreateGameEvent, uid);
        tbGameEvent = bizGameSystemDao.insertTbGameEvent(tbGameEvent);
        if (null == tbGameEvent.getId())
            new BizException(null, ErrorEnum.ERROR_DB.getLabel());
        logger.info("个人创建赛事成功.俱乐部ID:{},赛事ID{}", uid, tbGameEvent.getId());

        initGameSystemPk(reqPersonCreateGameEvent, uid, tbGameEvent);

        if (reqPersonCreateGameEvent.getIsDouble()) {             //双打添加消息推送
            gameMsgPush.doubleGamePust(tbGameEvent,
                    baseService.queryUserMsg(uid).getNickName(), reqPersonCreateGameEvent.getTeamMate().get(0));
        }
        GameEvent gameEvent = new GameEvent();
        gameEvent.setId(tbGameEvent.getId());
        //分享信息
        TbGameCommonParameter tbGameCommonParameter = baseService.queryTbGameCommonParameter(GameConstants.STADIUM_DEFAULT_GROUP_PARAMETER_KEY,
                MsgPush.GAME_OFFICIAL_EVENT_SHARE_MSG);
        TbGameCommonParameter tbGameCommonParameter1 = baseService.queryTbGameCommonParameter(GameConstants.STADIUM_DEFAULT_GROUP_PARAMETER_KEY,
                MsgPush.GAME_OFFICIAL_EVENT_SHARE_URL);
        gameEvent.setShareMsg(MsgPush.msgUtils(tbGameCommonParameter.getParameterValue(), tbGameEvent.getName()));  //分享

        gameEvent.setShareUrl(shareServerName+tbGameCommonParameter1.getParameterValue());
        return gameEvent;
    }

    public void initGameSystemPk(ReqPersonCreateGameEvent reqPersonCreateGameEvent, int uid, TbGameEvent tbGameEvent) throws Exception {
        if (reqPersonCreateGameEvent.getGameSystemType().intValue() == GameSystemConfigEnum.CONFIG_GAME_TYPE_PK.getId()) {
            List<Integer> teamMates = new ArrayList<>();
            teamMates.add(uid);
            if (CollectionUtils.isNotEmpty(reqPersonCreateGameEvent.getTeamMate())) {
                teamMates.addAll(reqPersonCreateGameEvent.getTeamMate());
            }

            Map<Integer, Integer> userTeam = gameSignUpService.outerGameSignUp(teamMates, tbGameEvent.getId(), false);
            GameRuleGenerate gameRuleGenerate = new GameRuleGenerate();
            gameRuleGenerate.setGameEventId(tbGameEvent.getId());
            gameRuleGenerate.setGameRoundId(gameRulePkServiceImpl.createGameRound(tbGameEvent.getId(), 2, null).get(0));
            if (reqPersonCreateGameEvent.getIsDouble()) {
                gameRuleGenerate.setIsDouble(true);
                List<Integer> teams = new ArrayList<>();
                teams.add(userTeam.get(uid));
                teams.add(userTeam.get(reqPersonCreateGameEvent.getTeamMate().get(0)));
                List<TbTeamDoubleAddendum> temp1 = new ArrayList<>();
                TbTeamDoubleAddendum addendum = new TbTeamDoubleAddendum();
                addendum.setId(-100);
                addendum.setGameEventId(tbGameEvent.getId());
                addendum.setTeamIdGson(new Gson().toJson(teams));
                temp1.add(addendum);
                gameRuleGenerate.setTbTeamDoubleAddendumList(temp1);
            }else {
                List<TbGameEventTeam> temp2 = new ArrayList<>();
                TbGameEventTeam tbGameEventTeam= new TbGameEventTeam();
                tbGameEventTeam.setId(userTeam.get(uid));
                tbGameEventTeam.setUid(uid);
                tbGameEventTeam.setGameEventId(tbGameEvent.getId());
                tbGameEventTeam.setType((byte) 0);
                temp2.add(tbGameEventTeam);
                gameRuleGenerate.setTbGameEventTeamList(temp2);
            }
            gameRulePkServiceImpl.createGameSchedule(tbGameEvent, gameRuleGenerate);
            TbGameEvent tbGameEventTemp = new TbGameEvent();
            tbGameEventTemp.setId(tbGameEvent.getId());
            tbGameEventTemp.setCurrentRoundId(gameRuleGenerate.getGameRoundId());
            bizGameSystemDao.updateTbGameEvent(tbGameEventTemp);
        }
    }

    public void validateCondition(ReqPersonCreateGameEvent reqPersonCreateGameEvent) {
        if (null == reqPersonCreateGameEvent.getLat() || null == reqPersonCreateGameEvent.getLng()) {
            throw new BizException(null, "经纬度不能为空");
        }
        if (reqPersonCreateGameEvent.getCategoryId().intValue() == GameConstants.CATEGORY_ID_FOOTBALL ||
                reqPersonCreateGameEvent.getCategoryId().intValue() == GameConstants.CATEGORY_ID_BASKETBALL) {
            throw new BizException(null, "个人对抗赛不支持足球和篮球赛事");
        }

        if (reqPersonCreateGameEvent.getGameSystemType().intValue() == GameSystemConfigEnum.CONFIG_GAME_TYPE_MIXED.getId()) {
            GameCategory gameCategory = gameEventTransfer.getGameCategoryById(reqPersonCreateGameEvent.getGameCategoryType().intValue());
            if (gameCategory.getMinNum().intValue() == gameCategory.getMaxNum().intValue() && gameCategory.getMinNum().intValue() == 2) {
                throw new BizException(null, "混合制暂不支持双打");
            }
        }
        if (gameEventTransfer.getGameCategoryById(reqPersonCreateGameEvent.getGameCategoryType().intValue()).getMinNum() == 2 &&
                gameEventTransfer.getGameCategoryById(reqPersonCreateGameEvent.getGameCategoryType().intValue()).getMaxNum() == 2) {
            reqPersonCreateGameEvent.setIsDouble(true);
            if (null == reqPersonCreateGameEvent.getTeamMate() || reqPersonCreateGameEvent.getTeamMate().size() != 1) {
                throw new BizException(null, "双打比赛必须邀请队友");
            }
        }
    }

    public TbGameEvent transferTbGameEvent(ReqPersonCreateGameEvent reqPersonCreateGameEvent, int uid) {
        TbGameEvent tbGameEvent = new TbGameEvent();
        tbGameEvent.setPrice(reqPersonCreateGameEvent.getPrice());
        tbGameEvent.setStartTime(new Date(reqPersonCreateGameEvent.getStartTime()));
        tbGameEvent.setEndTime(new Date(reqPersonCreateGameEvent.getEndTime()));
        tbGameEvent.setSignStartTime(new Date());
        tbGameEvent.setSignEndTime(new Date(reqPersonCreateGameEvent.getStartTime()));
        tbGameEvent.setSignEndTime(new Date());
        tbGameEvent.setCategoryId(reqPersonCreateGameEvent.getCategoryId());
        tbGameEvent.setType(GameConstants.PERSONAL_CREATE);
        tbGameEvent.setUid(uid);
        tbGameEvent.setClubId(0);
        tbGameEvent.setGameSystemType(reqPersonCreateGameEvent.getGameSystemType().byteValue());
        tbGameEvent.setGameCategoryType(reqPersonCreateGameEvent.getGameCategoryType());
        tbGameEvent.setGameGradeLevelType(reqPersonCreateGameEvent.getGameGradeLevel());
        tbGameEvent.setGameEventType((byte) GameTypeConfigEnum.CONFIG_GAME_EVENT_TYPE_PERSONAL.getId());
        tbGameEvent.setIsVisible((byte) 1);
        tbGameEvent.setGameDesc(reqPersonCreateGameEvent.getComments());
        tbGameEvent.setManagerMobile(reqPersonCreateGameEvent.getHostMobile());
        tbGameEvent.setPayType(reqPersonCreateGameEvent.getPayType());

        if (reqPersonCreateGameEvent.getTeamLimitNum() == 0) {
            tbGameEvent.setTeamLimitNum(Integer.MAX_VALUE);
            tbGameEvent.setInventoryLevel(Integer.MAX_VALUE);
        }else {
            tbGameEvent.setTeamLimitNum(reqPersonCreateGameEvent.getTeamLimitNum());
            tbGameEvent.setInventoryLevel(reqPersonCreateGameEvent.getTeamLimitNum());
        }
        RespUserInfoDetail user = baseService.queryUserMsg(uid);
        tbGameEvent.setManagerName(user.getNickName());
        MultiMedia multiMedia = new MultiMedia();
        Image image = new Image();
        if (StringUtils.isEmpty(reqPersonCreateGameEvent.getImage())) {
            List<TbGamePoster> posters = bizGameSystemDao.queryTbGamePosterList(reqPersonCreateGameEvent.getCategoryId());
            if (CollectionUtils.isNotEmpty(posters)) {
                image.setImageUrl(posters.get(new Random().nextInt(posters.size())).getUrl());
            }else {
                TbGameCommonParameter icon = baseService.queryTbGameCommonParameter(GameConstants.STADIUM_DEFAULT_GROUP_BASE_CONFIG_KEY,
                        GameConstants.BASE_CONFIG_KEY_OFFICIAL_HOST_ICON);
                image.setImageUrl(icon.getParameterValue());
            }
        }else {
            image.setImageUrl(reqPersonCreateGameEvent.getImage());
        }
        multiMedia.setType(GameConstants.IS_NOT_DELETE);   //图片
        multiMedia.setImage(image);
        tbGameEvent.setMultiMedia(new Gson().toJson(multiMedia));
        String gameCode = GameUtils.generateGameCode((byte) GameTypeConfigEnum.CONFIG_GAME_EVENT_TYPE_PERSONAL.getId(), reqPersonCreateGameEvent.getCategoryId(), 0, reqPersonCreateGameEvent.getGameSystemType().byteValue());
        tbGameEvent.setGameNumber(gameCode);
        String categoryName = "";
        if (reqPersonCreateGameEvent.getCategoryId().intValue() == 1) {
            categoryName = "篮球";
        }else if (reqPersonCreateGameEvent.getCategoryId().intValue() == 2) {
            categoryName = "羽毛球";
        }else if (reqPersonCreateGameEvent.getCategoryId().intValue() == 3) {
            categoryName = "足球";
        }else if (reqPersonCreateGameEvent.getCategoryId().intValue() == 4) {
            categoryName = "网球";
        }
        tbGameEvent.setName(user.getNickName()+"发起的"+categoryName + "赛");
        RespDistrict respDistrict = this.initRespDistrict(reqPersonCreateGameEvent.getLat(), reqPersonCreateGameEvent.getLng());
        tbGameEvent.setAddress(reqPersonCreateGameEvent.getAddress());
        tbGameEvent.setCityId(respDistrict.getCityId());
        if (null!=respDistrict.getLat()) {
            tbGameEvent.setLat(reqPersonCreateGameEvent.getLat());
        }
        if (null!=respDistrict.getLng()) {
            tbGameEvent.setLng(reqPersonCreateGameEvent.getLng());
        }
        if (null!=respDistrict.getId()) {
            tbGameEvent.setDistrictId(respDistrict.getId());
        }
        return tbGameEvent;
    }

    /**
     * 初始化区域位置
     *
     * */
    public RespDistrict initRespDistrict(Double lat, Double lng){
        RespDistrict respDistrict = new RespDistrict();
        if (null!=lat && lat >0 && null!=lng && lng > 0) {
            respDistrict.setLat(lat);
            respDistrict.setLng(lng);
            RespDistrict temp = baseService.getRespDistrictByLatAndLng(lat, lng);
            respDistrict.setCityId(6);
            respDistrict.setId(0);
            if (null!=temp) {
                if (null!=temp.getCityId()) {
                    respDistrict.setCityId(temp.getCityId());
                }
                if (null!=temp.getId()) {
                    respDistrict.setId(temp.getId());
                }
            }
        }
        return respDistrict;
    }

    @Override
    public APIResponse<RespGameSystemAndGameCategory> gameCategoryAndSystem(Integer categoryId, Byte gameType) {
        List<GameSystemConfigEnum> systems = new ArrayList<>();
        List<GameCategoryConfigEnum> categories = new ArrayList<>();
        List<GameGradeLevelConfigEnum> gradeLevels = new ArrayList<>();
        List<PayTypeEnum> payTypes = new ArrayList<>();
        switch(categoryId) {
            case 3:  //足球
                systems.add(GameSystemConfigEnum.CONFIG_GAME_TYPE_SWISS);
                systems.add(GameSystemConfigEnum.CONFIG_GAME_TYPE_WASHED);
                systems.add(GameSystemConfigEnum.CONFIG_GAME_TYPE_CIRCLE);
                systems.add(GameSystemConfigEnum.CONFIG_GAME_TYPE_MIXED);

                categories.add(GameCategoryConfigEnum.CONFIG_GAME_CATEGORY_V5);
                categories.add(GameCategoryConfigEnum.CONFIG_GAME_CATEGORY_V7);
                categories.add(GameCategoryConfigEnum.CONFIG_GAME_CATEGORY_V9);
                categories.add(GameCategoryConfigEnum.CONFIG_GAME_CATEGORY_V11);

                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_1);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_2);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_3);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_4);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_5);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_6);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_7);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_8);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_9);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_10);

                payTypes.add(PayTypeEnum.CONFIG_PAY_TYPE_AA);
                payTypes.add(PayTypeEnum.CONFIG_PAY_TYPE_ME);
                break;
            case 1:  //篮球
                systems.add(GameSystemConfigEnum.CONFIG_GAME_TYPE_SWISS);
                systems.add(GameSystemConfigEnum.CONFIG_GAME_TYPE_WASHED);
                systems.add(GameSystemConfigEnum.CONFIG_GAME_TYPE_CIRCLE);
                systems.add(GameSystemConfigEnum.CONFIG_GAME_TYPE_MIXED);

                categories.add(GameCategoryConfigEnum.CONFIG_GAME_CATEGORY_V3);
                categories.add(GameCategoryConfigEnum.CONFIG_GAME_CATEGORY_V4);
                categories.add(GameCategoryConfigEnum.CONFIG_GAME_CATEGORY_V5);

                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_1);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_2);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_3);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_4);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_5);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_6);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_7);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_8);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_9);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_10);

                payTypes.add(PayTypeEnum.CONFIG_PAY_TYPE_AA);
                payTypes.add(PayTypeEnum.CONFIG_PAY_TYPE_ME);
                break;
            case 4:  //网球
                systems.add(GameSystemConfigEnum.CONFIG_GAME_TYPE_SWISS);
                systems.add(GameSystemConfigEnum.CONFIG_GAME_TYPE_WASHED);
                systems.add(GameSystemConfigEnum.CONFIG_GAME_TYPE_CIRCLE);
                systems.add(GameSystemConfigEnum.CONFIG_GAME_TYPE_MIXED);

                categories.add(GameCategoryConfigEnum.CONFIG_GAME_CATEGORY_MALE_ONLY);
                categories.add(GameCategoryConfigEnum.CONFIG_GAME_CATEGORY_FEMALE_ONLY);
                categories.add(GameCategoryConfigEnum.CONFIG_GAME_CATEGORY_MALE_DOUBLE);
                categories.add(GameCategoryConfigEnum.CONFIG_GAME_CATEGORY_FEMALE_DOUBLE);
                categories.add(GameCategoryConfigEnum.CONFIG_GAME_CATEGORY_MIXED_DOUBLE);
                categories.add(GameCategoryConfigEnum.CONFIG_GAME_CATEGORY_NOT_KNOW_ONLY);
                categories.add(GameCategoryConfigEnum.CONFIG_GAME_CATEGORY_NOT_KNOW_DOUBLE);

                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_1);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_1_5);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_2);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_2_5);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_3);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_3_5);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_4);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_4_5);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_5);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_5_5);


                if (gameType.intValue() == GameTypeConfigEnum.CONFIG_GAME_EVENT_TYPE_INTERNAL.getId()) {
                    payTypes.add(PayTypeEnum.CONFIG_PAY_TYPE_FREE);
                }else {
                    payTypes.add(PayTypeEnum.CONFIG_PAY_TYPE_AA);
                    payTypes.add(PayTypeEnum.CONFIG_PAY_TYPE_ME);
                }
                payTypes.add(PayTypeEnum.CONFIG_PAY_TYPE_ONLINE);
                break;
            case 2:  //羽毛球
                systems.add(GameSystemConfigEnum.CONFIG_GAME_TYPE_SWISS);
                systems.add(GameSystemConfigEnum.CONFIG_GAME_TYPE_WASHED);
                systems.add(GameSystemConfigEnum.CONFIG_GAME_TYPE_CIRCLE);
                systems.add(GameSystemConfigEnum.CONFIG_GAME_TYPE_MIXED);

                categories.add(GameCategoryConfigEnum.CONFIG_GAME_CATEGORY_MALE_ONLY);
                categories.add(GameCategoryConfigEnum.CONFIG_GAME_CATEGORY_FEMALE_ONLY);
                categories.add(GameCategoryConfigEnum.CONFIG_GAME_CATEGORY_MALE_DOUBLE);
                categories.add(GameCategoryConfigEnum.CONFIG_GAME_CATEGORY_FEMALE_DOUBLE);
                categories.add(GameCategoryConfigEnum.CONFIG_GAME_CATEGORY_MIXED_DOUBLE);
                categories.add(GameCategoryConfigEnum.CONFIG_GAME_CATEGORY_NOT_KNOW_ONLY);
                categories.add(GameCategoryConfigEnum.CONFIG_GAME_CATEGORY_NOT_KNOW_DOUBLE);

                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_1);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_2);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_3);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_4);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_5);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_6);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_7);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_8);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_9);
                gradeLevels.add(GameGradeLevelConfigEnum.CONFIG_GAME_GRADE_LEVEL_10);

                if (gameType.intValue() == GameTypeConfigEnum.CONFIG_GAME_EVENT_TYPE_INTERNAL.getId()) {
                    payTypes.add(PayTypeEnum.CONFIG_PAY_TYPE_FREE);
                }else {
                    payTypes.add(PayTypeEnum.CONFIG_PAY_TYPE_AA);
                    payTypes.add(PayTypeEnum.CONFIG_PAY_TYPE_ME);
                }
                payTypes.add(PayTypeEnum.CONFIG_PAY_TYPE_ONLINE);
                break;
            default:
                logger.debug("非四大球,栏目id异常");
        }

        return APIResponse.returnSuccess(gameEventService.generateGameSystemAndGameCategory(categories, systems, gradeLevels, payTypes, categoryId));
    }
}
